window._MCAC = {

    _SSNPC:[],

    _KJNPC:['流浪者','防御者','支援者','毁灭者','送葬者'],

    //创建道具动作
    getItemAction:function(sence,item,target,targetArr,player,skillParam){

        var itemConf = _FIGHTITEM[item];

        var itemani = itemConf.ani;

        //var itemType = itemConf.skilltype;

        var itemTime = _GRM.skillAni[itemani].nmb*0.1;

        //var skillx = target?target.x:null;

        //var skilly = target?target.y:null;

        //console.log('技能动作',skill,skillTime,skillConf);

        var runActions = [];

        //播放技能动画动作
        runActions.push(cc.callFunc(function(){
            sence.showAttackName(item,_CHESSFIGHT.getPlayerNodeByCode(player));
            //sence.playSkill(itemani,skillx,skilly);
        },sence));
        runActions.push(cc.delayTime(itemTime));

        //炉石
        if(itemConf.isrun){
            runActions.push(cc.callFunc(function(){
                
                sence.jumpSuccess();

            },sence));
            return runActions;
        }

        //依次结算技能效果动作
        for(var i=0;i<targetArr.length;i++){
            var targetObj = targetArr[i];
            var targetInfo = targetObj.info;
            var targetNode = targetObj.node;

            runActions.push(_MCAC.getItemEffectAction(item,player,targetInfo,targetNode,sence,itemani));
        }
        runActions.push(cc.delayTime(0.5));
        //回合结束动作
        runActions.push(_MCAC.getActionEnd(sence));

        return runActions;
    },

    getSkillAction:function(sence,skill,target,targetArr,player,skillParam){

        var skillConf = _SKILL[skill];

        var skillani = _SKILL[skill].ani;

        var skillType = _SKILL[skill].skilltype;

        var skillTime = _GRM.skillAni[skillani].nmb*0.1;

        var skillx = target?target.x:null;

        var skilly = target?target.y:null;

        //console.log('技能动作',skill,skillTime,skillConf);

        var runActions = [];

        if(skillType=="moveRole"){//拉人技能

            var tmppos = _CU.randomObj(skillParam.enablePosArr);
            var targetPlayer = skillParam.targetPlayer;
            skillx = tmppos[0];
            skilly = tmppos[1];

            //播放技能动画动作
            runActions.push(cc.callFunc(function(){
    
                sence.playSkill(skillani,skillx,skilly);
                _MCAC.addSkillSelfStatus(player,skill);
                targetPlayer.info.chessPos = {x:skillx,y:skilly};
                sence.refreshPlayerNodeMap();
                sence.showAttackName(skill,_CHESSFIGHT.getPlayerNodeByCode(player));

            },sence));
            runActions.push(cc.delayTime(skillTime));

        }else if(skillType=="run"){

            //播放技能动画动作
            runActions.push(cc.callFunc(function(){
                var tempplayernode  = _CHESSFIGHT.getPlayerNodeByCode(player);
                
                sence.playSkillOnPlayer(skillani,player);
                sence.showAttackName(skill,tempplayernode);
                //sence.refreshPlayerNodeMap();

            },sence));
            runActions.push(cc.delayTime(skillTime));

            runActions.push(cc.callFunc(function(){
                
                sence.jumpSuccess();

            },sence));

            return runActions;
        }else if(skillType=="getRole"){//招安技能

            var magicPer = _ROLEDATA.getRoleDataOfPlayer(player).magicPer/100;
            //播放技能动画动作
            runActions.push(cc.callFunc(function(){
                sence.showAttackName(skill,_CHESSFIGHT.getPlayerNodeByCode(player));
                //sence.playSkill(skillani,skillx,skilly);
            },sence));
            runActions.push(cc.delayTime(skillTime));

            //依次结算技能效果动作
            for(var i=0;i<targetArr.length;i++){
                var targetObj = targetArr[i];
                var targetInfo = targetObj.info;
                var targetNode = targetObj.node;

                if(Math.random()<(skillConf.per+magicPer)){

                    runActions.push(
                        cc.callFunc(function(){
                            if(!this.targetInfo.isboss&&!_ROLEDATA.getRealAttr(this.targetInfo,'clearHeart')){
                                if(
                                    this.targetInfo.hp>0
                                    &&(
                                        this.targetInfo.isplayer
                                        ||_GAMEDATAHELPER.oprMoney(-this.targetInfo.hp)
                                    )
                                ){
                                    //点亮图鉴
                                    _GAMEDATAHELPER.signNpcTj(this.targetInfo.npctype);
                                    _GAMEDATAHELPER.signXwTjByRole(this.targetInfo);
                                    this.targetInfo.isplayer = !this.targetInfo.isplayer;

                                    if(this.targetInfo.isplayer&&!this.targetInfo.isZhaohuan){
                                        this.targetInfo.equip=[];
                                        window.gameData.playerTeamBack.unshift(this.targetInfo);
                                    }

                                    _MFN.refreshPlayerNode(this.targetNode,this.targetInfo);
                                    sence.playSkillOnPlayer(skillani,this.targetInfo);
                                    sence.showAttackName("给大爷跪了",this.targetNode);
                                }else{
                                    sence.showAttackName("没钱免谈",this.targetNode);
                                }
                            }else{
                                sence.showAttackName("好大的胆子!",this.targetNode);
                            }
                        },{
                            targetInfo:targetInfo,
                            targetNode:targetNode
                        })
                    );

                    
                }else{

                    runActions.push(
                        cc.callFunc(function(){
                            //sence.playSkillOnPlayer(skillani,this.targetInfo);
                            sence.showAttackName("无耻小人",this.targetNode);
                        },{
                            targetInfo:targetInfo,
                            targetNode:targetNode
                        })
                    );

                }

                
            }
            runActions.push(cc.delayTime(0.5));
            //runActions.push(cc.delayTime(skillTime));

        }else if(skillType=="moveAttack"){//闪击技能

            var tmppos = _CU.randomObj(skillParam.enablePosArr);
            var targetPlayer = skillParam.targetPlayer;
            skillx = tmppos[0];
            skilly = tmppos[1];
            var targetInfo = targetPlayer.info;
            var targetNode = targetPlayer.node;

            //修改施法者坐标
            runActions.push(cc.callFunc(function(){
                if(player&&player.chessPos){
                    sence.playSkill(skillani,player.chessPos.x,player.chessPos.y);
                }
                player.chessPos = {x:skillx,y:skilly};
            },sence));
            runActions.push(cc.delayTime(0.5));

            //播放技能动画
            runActions.push(cc.callFunc(function(){
                var tempPlayerNode = _CHESSFIGHT.getPlayerNodeByCode(player);
                _MCAC.addSkillSelfStatus(player,skill);
                sence.refreshPlayerNodeMap();
                sence.switchPlayerDirAndActtack(tempPlayerNode,targetInfo.chessPos);
                sence.showAttackName(skill,tempPlayerNode);
                //sence.playSkill(skillani,skillx,skilly);
            },sence));
            runActions.push(cc.delayTime(skillTime));
            
            //结算伤害
            runActions.push(_MCAC.getDamageAction(skill,player,targetInfo,targetNode,sence,'attack_bao'));
            runActions.push(cc.delayTime(0.5));

        }else if(skillType=="move"){//传送技能
            skillx = skillParam.x;
            skilly = skillParam.y;

            //播放技能动画动作
            runActions.push(cc.callFunc(function(){
            
                sence.playSkill(skillani,_CHESSFIGHT.targetX,_CHESSFIGHT.targetY);
                _MCAC.addSkillSelfStatus(player,skill);
                sence.currentPlayer.chessPos = skillParam;
                sence.showAttackName(skill,_CHESSFIGHT.getPlayerNodeByCode(player));
                //sence.refreshPlayerNodeMap();

            },sence));
            runActions.push(cc.delayTime(skillTime));

            //修改施法者坐标
            runActions.push(cc.callFunc(function(){
                
                sence.playSkill(skillani,skillx,skilly);
                sence.refreshPlayerNodeMap();

            },sence));
            runActions.push(cc.delayTime(0.5));

        }else if(skillType=="biansen"){//变身技能

            //播放技能动画动作
            runActions.push(cc.callFunc(function(){
                var tempplayernode  = _CHESSFIGHT.getPlayerNodeByCode(player);
                
                if(_MCAC.doConceAnimals(skillConf,player,tempplayernode)){
                    sence.playSkillOnPlayer(skillani,player);
                    sence.showAttackName(skill,tempplayernode);
                    sence.refreshPlayerNodeMap();
                }else{
                    sence.showAttackName("变化失败",tempplayernode);
                }
                

            },sence));
            runActions.push(cc.delayTime(skillTime));

        }else if(skillType=="fenshen"){//召唤技能

            //播放技能动画动作
            runActions.push(cc.callFunc(function(){
                _MCAC.addSkillSelfStatus(player,skill);
                sence.showAttackName(skill,_CHESSFIGHT.getPlayerNodeByCode(player));
            },sence));
            var enablePosArr = _MCFW.getPosOfTargetForJump(_CHESSFIGHT.targetX,_CHESSFIGHT.targetY);
            var fsnmb = skillConf.nmb?skillConf.nmb:1;
            var playerData = _ROLEDATA.getRoleDataOfPlayer(player);
            if(playerData.fanzhi){
                fsnmb+=playerData.fanzhi;
            }

            fsnmb = fsnmb>enablePosArr.length?enablePosArr.length:fsnmb;
            
            runActions.push(cc.callFunc(function(){
                for(var i=0;i<fsnmb;i++){
                    _MCAC.doFenshen(skillConf,player,sence);
                    sence.refreshPlayerNodeMap();
                }
            },sence));
            runActions.push(cc.delayTime(skillTime));
            
        }else if(skillType=="zibao"){

            var cutHp = player.hp;

            //播放技能动画动作
            runActions.push(cc.callFunc(function(){
                sence.showAttackName(skill,_CHESSFIGHT.getPlayerNodeByCode(player));
                player.hp = 0;
                sence.playSkillOnPlayer(skillani,player);
                _MFN.refreshPlayerInfo(_CHESSFIGHT.getPlayerNodeByCode(player),player);
            },sence));
            runActions.push(cc.delayTime(skillTime));

            //依次结算技能效果动作
            for(var i=0;i<targetArr.length;i++){
                var targetObj = targetArr[i];
                var targetInfo = targetObj.info;
                var targetNode = targetObj.node;
                runActions.push(_MCAC.getZbDamageAction(skill,player,targetInfo,targetNode,sence,skillani,cutHp));
            }

            runActions.push(cc.delayTime(0.5));

        }else if(skillType=="anqi"){

            var randomItem = _MCAC.getRandomItem(player.isplayer);
            if(randomItem){
                var randomConf = _FIGHTITEM[randomItem];
                var itemani = randomConf.ani;

                //播放技能动画动作
                runActions.push(cc.callFunc(function(){
                    sence.showAttackName(skill,_CHESSFIGHT.getPlayerNodeByCode(player));
                    if(player.isplayer){
                        _CU.cutArrNmb(window.gameData.fightItem,randomItem);
                    }
                },sence));
                runActions.push(cc.delayTime(skillTime));

                //依次结算技能效果动作
                for(var i=0;i<targetArr.length;i++){
                    var targetObj = targetArr[i];
                    var targetInfo = targetObj.info;
                    var targetNode = targetObj.node;

                    runActions.push(_MCAC.getItemEffectAction(randomItem,player,targetInfo,targetNode,sence,itemani));
                }

                runActions.push(cc.delayTime(0.5));
            }else{
                
                runActions.push(cc.callFunc(function(){
                    sence.showAttackName(skill,_CHESSFIGHT.getPlayerNodeByCode(player));
                },sence));
                runActions.push(cc.delayTime(0.5));
            }

        }else{//范围技能

            //播放技能动画动作
            runActions.push(cc.callFunc(function(){
                sence.showAttackName(skill,_CHESSFIGHT.getPlayerNodeByCode(player));
                _MCAC.addSkillSelfStatus(player,skill);
            },sence));
            
            //runActions.push(cc.delayTime(skillTime));

            //依次结算技能效果动作
            for(var i=0;i<targetArr.length;i++){
                var targetObj = targetArr[i];
                var targetInfo = targetObj.info;
                var targetNode = targetObj.node;

                if(skillType=='attack'){
                        runActions.push(_MCAC.getDamageAction(skill,player,targetInfo,targetNode,sence,skillani));
                }else if(skillType=='buff'){
                        runActions.push(_MCAC.getBuffAction(skill,player,targetInfo,targetNode,sence,skillani));
                }
            }

            runActions.push(cc.delayTime(0.5));

        }
        
        //回合结束动作
        runActions.push(_MCAC.getActionEnd(sence));

        return runActions;
    },

    getRandomAnimals:function(historyAnimals){
        var enablearr = [];
        for(var key in _ANIMALS){
            if(!historyAnimals||!historyAnimals[key]){
                enablearr.push(key);
            }
        }

        if(enablearr.length>0){
            return _CU.randomObj(enablearr);
        }

        return null;
    },

    //变身
    doConceAnimals:function(skillObj,player,playerNode){

        //console.log('变身1:',skillObj);
        var skillanimals = skillObj.animals;

        //七十二变
        if(skillanimals=="随机"){
            skillanimals=_MCAC.getRandomAnimals(player.historyAnimals);
        }

        if(
            skillanimals
            &&_ANIMALS[skillanimals]
            &&(
                !player.historyAnimals
                ||!player.historyAnimals[skillanimals]
            )
        ){
            var animalsConf = _ANIMALS[skillanimals];

            //console.log('变身2:',animalsConf);

            _MFN.switchAni(playerNode,animalsConf.pf);

            //var oldplayerData = _ROLEDATA.getRoleDataOfPlayer(player);
            player.animals = skillanimals;
            if(!player.historyAnimals){
                player.historyAnimals={};
            }
            player.historyAnimals[skillanimals]=1;
            var newplayerData = _ROLEDATA.getRoleDataOfPlayer(player);
            player.hp = newplayerData.maxHp;
            //player.mg = newplayerData.maxMagic;

            return true;
        }

        return false;

    },

    getRandomSS:function(){
        if(_MCAC._SSNPC.length<=0){
            for(var npc in _NPC){
                if(_NPC[npc].level=="SS"&&_NPC[npc].race!='mo')
                _MCAC._SSNPC.push(npc);
            }
        }

        return _CU.randomObj(_MCAC._SSNPC);

    },
    //分身
    doFenshen:function(skillObj,player,sence){

        var enablePosArr = _MCFW.getPosOfTargetForJump(_CHESSFIGHT.targetX,_CHESSFIGHT.targetY);
        if(!enablePosArr||enablePosArr.length<=0){
            return;
        }else{
            var randomPos = _CU.randomObj(enablePosArr);
                randomPos = {x:randomPos[0],y:randomPos[1]};

            var zhplayer = skillObj.npc;
            if(zhplayer=="随机"){
                zhplayer=_MCAC.getRandomSS();
            }
            var lv = _ROLEDATA.getRoleDataOfPlayer(player).lv;
            var newplayer = skillObj.npc=="self"?_CU.cloneObj(player):_MCFC.createNpcRole(zhplayer,{dzlevel:0,lv:lv});


                newplayer.isplayer = player.isplayer;
                newplayer.isZhaohuan = true;
                newplayer.sourcePlayer = player;
                newplayer.isboss = false;
            
            //分身失去分身技能
            if(skillObj.npc=="self"){
                if(newplayer.skill&&newplayer.skill.length>0){
                    for(var i=0;i<newplayer.skill.length;){
                        var tempskillname = newplayer.skill[i];
                        if(
                            _SKILL[tempskillname]
                            &&_SKILL[tempskillname].skilltype=="fenshen"
                            &&_SKILL[tempskillname].npc=="self"
                        ){
                            newplayer.skill.splice(i,1);
                        }else{
                            i++;
                        }
                    }
                }
                //分身血量低于本体 吸收火力 且优先本体行动
                if(newplayer.hp>1){
                    newplayer.hp--;
                }
            }

            _CHESSFIGHT.initOneFighterReal(newplayer,randomPos,player.isplayer,(player.eg+1),0);

            sence.playSkillOnPlayer(skillObj.ani,newplayer);
        }
    },

    //召唤科技单位
    doKejiFenshen:function(player,sence){
        var x = player.chessPos.x;
        var y = player.chessPos.y;
        var enablePosArr = _MCFW.getPosOfTargetForJump(x,y);
        if(!enablePosArr||enablePosArr.length<=0){
            return;
        }else{
            var randomPos = _CU.randomObj(enablePosArr);
                randomPos = {x:randomPos[0],y:randomPos[1]};
            var tempNpc = _CU.randomObj(_MCAC._KJNPC);
            var newplayer =_CROF.createNpcRole(tempNpc,{dzlevel:0,lv:1000});
                newplayer.isplayer = player.isplayer;
                newplayer.isZhaohuan = true;
                newplayer.sourcePlayer = player;

            _CHESSFIGHT.initOneFighterReal(newplayer,randomPos,player.isplayer,0,0);
            sence.playSkillOnPlayer('biansen',newplayer);
        }
    },


    //给自身附加状态或者能量
    addSkillSelfStatus:function(player,skill){

        if(_SKILL[skill]){

            if(_SKILL[skill].selfstatus){
                _STATUSHELPERCHESS.addStatus(player,_SKILL[skill].selfstatus,player);
            }
            if(_SKILL[skill].selfeg&&Math.random()<_CS.selfeg){
                player.eg+=_SKILL[skill].selfeg;
            }
            _MFN.refreshPlayerInfo(_CHESSFIGHT.getPlayerNodeByCode(player),player);
        }

    },


    //给目标附加状态或者能量
    addSkillStatus:function(player,skill,sourcePlayer){

        if(_SKILL[skill]){

            if(
                _SKILL[skill].status
                &&(
                    _SKILL[skill].skilltype!='attack'
                    ||Math.random()<0.5
                )
            ){
                _STATUSHELPERCHESS.addStatus(player,_SKILL[skill].status,sourcePlayer);
            }

            if(
                _SKILL[skill].targeteg
                &&Math.random()<0.5
            ){

                var tempplayerData = _ROLEDATA.getRoleDataOfPlayer(player);

                if(!tempplayerData.strongEnergy||_SKILL[skill].targeteg>0){
                    player.eg+=_SKILL[skill].targeteg;
                    if(player.eg<0){
                        player.eg=0;
                    }
                }
            }

            _MFN.refreshPlayerNode(_CHESSFIGHT.getPlayerNodeByCode(player),player);
        }

    },

    //给目标附加状态或者能量
    addItemStatus:function(player,item,sourcePlayer){

        var itemConf = _FIGHTITEM[item];

        if(itemConf){

            if(itemConf.status){
                _STATUSHELPERCHESS.addStatus(player,itemConf.status,sourcePlayer);
            }

            if(itemConf.targeteg){
                player.eg+=itemConf.targeteg;
                if(player.eg<0){
                    player.eg=0;
                }
            }

            _MFN.refreshPlayerNode(_CHESSFIGHT.getPlayerNodeByCode(player),player);
        }

    },

    getItemEffectAction:function(item,player,targetInfo,targetNode,sence,itemani){
        
        var result = _MFD.getDamageOfItem(player,targetInfo,item);

        var itemConf  = _FIGHTITEM[item];

        if(result.damage){//伤害类道具

            if(!result.isMiss){
                _MCAC.addItemStatus(targetInfo,item,player);
            }

            return cc.callFunc(function(){
                sence.behit(this.player,this.targetInfo,this.targetNode,this.result,itemani,false,true);
            },{
                targetInfo:targetInfo,
                targetNode:targetNode,
                result:result,
                player:player
            });

        }else if(itemConf.isgetRole==1){//精灵球

            var hpper = itemConf.hpper;

            if(
                !_CHESSFIGHT.isTaskModel()
                &&Math.random()<(itemConf.per)
            ){

                var skillani = itemConf.ani;
                var itemqua = itemConf.qua;
                var targetqua = _NPC[targetInfo.npctype].level;
                var targetData = _ROLEDATA.getRoleDataOfPlayer(targetInfo);
                var targetHpPer = targetInfo.hp/targetData.maxHp;

                return   cc.callFunc(function(){
                        if(
                            this.targetInfo.hp>0
                            &&!_RHM.comparaLevel(targetqua,itemqua)
                            &&!_ROLEDATA.getRealAttr(this.targetInfo,'clearHeart')
                        ){
                            if(targetHpPer<=hpper){
                                //点亮图鉴
                                _GAMEDATAHELPER.signNpcTj(this.targetInfo.npctype);
                                _GAMEDATAHELPER.signXwTjByRole(this.targetInfo);
                                this.targetInfo.isplayer = !this.targetInfo.isplayer;

                                if(this.targetInfo.isplayer&&!this.targetInfo.isZhaohuan){
                                    this.targetInfo.equip=[];
                                    window.gameData.playerTeamBack.unshift(this.targetInfo);
                                }

                                _MFN.refreshPlayerNode(this.targetNode,this.targetInfo);
                                sence.playSkillOnPlayer(skillani,this.targetInfo);
                                sence.showAttackName("给大爷跪了",this.targetNode);
                            }else{
                                sence.showAttackName("血量需要低于"+hpper,this.targetNode);
                            }
                        }else{
                            sence.showAttackName("什么档次也想收我",this.targetNode);
                        }
                    },{
                        targetInfo:targetInfo,
                        targetNode:targetNode
                    })
                

                
            }else{

                return cc.callFunc(function(){
                    //sence.playSkillOnPlayer(skillani,this.targetInfo);
                    sence.showAttackName("无耻小人",this.targetNode);
                },{
                    targetInfo:targetInfo,
                    targetNode:targetNode
                });
            }

        }{
            return cc.callFunc(function(){

                var itemConf = _FIGHTITEM[this.itemName];

                if(!result.isMiss){
    
                    var tipsArr = [];
                    var addhp = _MFD.getHpAddOfItem(this.player,this.itemName);
                    var addmg = _MFD.getMagicAddOfItem(this.player,this.itemName);
    
                    if(addhp){
                        var realhp = _MFD.addHp(this.targetInfo,addhp);
                        tipsArr.push({msg:"回血"+_CU.getUnitNmb(realhp),color:_CS.hpcolor});
                    }
    
                    if(addmg){
                        var realmagic = _MFD.addMagic(this.targetInfo,addmg);
                        tipsArr.push({msg:"回蓝"+_CU.getUnitNmb(realmagic),color:_CS.langcolor});
                    }
    
                    if(itemConf.status&&_STATUSCONFCHESS[itemConf.status]){
                        _MCAC.addItemStatus(this.targetInfo,this.itemName,this.player);
                        tipsArr.push({msg:_STATUSCONFCHESS[itemConf.status].name,color:null});
                    }
    
                    sence.showTips(tipsArr,this.targetNode);
                    sence.playSkillOnPlayer(itemani,this.targetInfo);
                    _MFN.refreshPlayerInfo(this.targetNode,this.targetInfo);
    
                }else{
    
                    sence.showDamage("miss",null,this.targetNode);
    
                }
            },{
                targetInfo:targetInfo,
                targetNode:targetNode,
                itemName:item,
                player:player,
                playerData:_ROLEDATA.getRoleDataOfPlayer(player)
            });
        }
    },

    getDamageAction:function(skill,player,targetInfo,targetNode,sence,ani){
        var result = _MFD.getDamageOfSkill(player,targetInfo,skill);

        if(!result.isMiss){

            _MCAC.addSkillStatus(targetInfo,skill,player);

        }

        return cc.callFunc(function(){
            sence.behit(this.player,this.targetInfo,this.targetNode,this.result,ani,false,false);
        },{
            targetInfo:targetInfo,
            targetNode:targetNode,
            result:result,
            player:player
        });
    },

    getZbDamageAction:function(skill,player,targetInfo,targetNode,sence,ani,cutHp){
        var result = _MFD.getDamageOfSkill(player,targetInfo,skill);

        if(!result.isMiss){

            _MCAC.addSkillStatus(targetInfo,skill,player);
            result.damage = cutHp;
        }

        return cc.callFunc(function(){
            sence.behit(this.player,this.targetInfo,this.targetNode,this.result,ani,false,true);
        },{
            targetInfo:targetInfo,
            targetNode:targetNode,
            result:result,
            player:player
        });
    },

    getBuffAction:function(skillName,player,targetInfo,targetNode,sence,ani){
        
        return cc.callFunc(function(){
            //sence.beBuff(this.targetInfo,this.targetNode,this.result);
            var targetData = _ROLEDATA.getRoleDataOfPlayer(this.targetInfo);
            var missPer = this.playerData.hit>targetData.miss?0:(targetData.miss-this.playerData.hit);
            if(missPer>_CS.maxPer){
                missPer=_CS.maxPer;
            }
            var skillConf = _SKILL[this.skillName];
            var skillPer = skillConf.per;

            if(skillPer&&this.playerData.magicPer){
                skillPer+=this.playerData.magicPer/100;
            }

            //console.log('最终技能命中',skillPer);

            if(
                !skillConf.per
                ||(
                    Math.random()<skillPer//技能命中
                    &&Math.random()>(missPer/100)//角色命中
                )
            ){

                var tipsArr = [];
                var addhp = _MFD.getHpAddOfSkill(this.player,this.skillName);
                var addmg = _MFD.getMagicAddOfSkill(this.player,this.skillName);

                if(addhp){
                    var realhp = _MFD.addHp(this.targetInfo,addhp);
                    tipsArr.push({msg:"回血"+_CU.getUnitNmb(realhp),color:_CS.hpcolor});
                }

                if(addmg){
                    var realmagic = _MFD.addMagic(this.targetInfo,addmg);
                    tipsArr.push({msg:"回蓝"+_CU.getUnitNmb(realmagic),color:_CS.langcolor});
                }

                if(skillConf.status&&_STATUSCONFCHESS[skillConf.status]){
                    _MCAC.addSkillStatus(this.targetInfo,this.skillName,this.player);
                    tipsArr.push({msg:_STATUSCONFCHESS[skillConf.status].name,color:null});
                }

                if(skillConf.targeteg){
                    this.targetInfo.eg+=skillConf.targeteg;
                    tipsArr.push({msg:"能量"+skillConf.targeteg,color:null});
                }

                sence.showTips(tipsArr,this.targetNode);
                sence.playSkillOnPlayer(ani,this.targetInfo);
                _MFN.refreshPlayerInfo(this.targetNode,this.targetInfo);

            }else{

                sence.showDamage("miss",null,this.targetNode);

            }
        },{
            targetInfo:targetInfo,
            targetNode:targetNode,
            skillName:skillName,
            player:player,
            playerData:_ROLEDATA.getRoleDataOfPlayer(player)
        });

    },

    getRandomItem:function(isplayer){

        //挑战模式下禁止使用道具
        if(_MTZ.isTzModel()){
            return null;
        }

        if(isplayer){
            for(var i=0;i<window.gameData.fightItem.length;i++){
                var itemobj = window.gameData.fightItem[i].type;
                if(
                    !window.gameData.fightItem[i].isLock
                    &&_FIGHTITEM[itemobj]
                    &&_FIGHTITEM[itemobj].skilltype=="attack"
                    &&_FIGHTITEM[itemobj].target=="army"){
                    //console.log('使用',itemobj);
                    return itemobj;
                }

            }

            return null;
        }else{
            return "冰砖";
        }
    },

    getActionEnd:function(sence){

        return cc.callFunc(function(){
                    sence.actionIndex++;
                    sence.playerDoAction();
                },sence);

    }

}